(function() {
    var myApp = angular.module('myApp');

    myApp.controller("myLogController", function($scope, $rootScope, $log, myTableOption, reqDataByAjax) {

        // TAB显示之后，调整表格大小
        $scope.$on("shown.bs.tab", function(event, element, target) {
            if (target.is('#loglist')) {
                $scope.$root.$broadcast('resize.table', '#logtable');
            }
        });

        $scope.option = myTableOption;
        $scope.option.ajax = ajax;

        function ajax(data, callback, settings) {
            reqDataByAjax("/scheduling/api/settings/log/getall", data).then(function (ret) {
                callback({
                    "draw": data.draw,
                    "recordsTotal": ret[1][0].recordsTotal,
                    "recordsFiltered": ret[2][0].recordsFiltered,
                    "data": ret[0]
                });
            });
        }
    });

    myApp.controller("deleteLogController", function($scope, $log, reqDataByAjax) {
        $scope.ok = function() {
            reqDataByAjax("/scheduling/api/settings/log/delete", $scope.$root.selectedUsers, "POST").then(function() {
                // 保存后刷新用户列表
                $scope.$root.$broadcast("refresh.table", "#logtable");
            });
        };
    });

})();

